#include <climits>
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int dp[n + 1][n + 1];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int x;
            cin >> x;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + x;
        }
    }
    int my_max = INT_MIN;
    for (int x1 = 1; x1 <= n; x1++)
    {
        for (int y1 = 1; y1 <= n; y1++)
        {
            for (int x2 = x1; x2 <= n; x2++)
            {
                for (int y2 = y1; y2 <= n; y2++)
                {
                    my_max = max(my_max, dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1]);
                }
            }
        }
    }
    cout << my_max << endl;
    return 0;
}

struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};
 
class Solution {
public:
    int length(TreeNode* pRoot)
    {
        if (pRoot == nullptr)
        {
            return 0;
        }
        return max(length(pRoot->left), length(pRoot->right)) + 1;
    }

    bool IsBalanced_Solution(TreeNode* pRoot) {
        // write code here
        if (pRoot == nullptr)
        {
            return true;
        }
        int left = length(pRoot->left);
        int right = length(pRoot->right);
        if (abs(left - right) > 1)
        {
            return false;
        }
        return IsBalanced_Solution(pRoot->right) && IsBalanced_Solution(pRoot->left);
    }
};

int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int hash1[2] = { 0 };
    int hash2[2] = { 0 };
    for (auto s : str)
    {
        hash1[s - '0']++;
    }
    int ret = 0;
    int left = 0;
    int right = 0;
    while (right < n)
    {
        hash2[str[right] - '0']++;
        if (hash2[str[right] - '0'] == hash1[str[right] - '0'] / 2 && right - left + 1 == n / 2)
        {
            ret++;
            hash2[str[left] - '0']--;
            left++;
        }
        right++;
    }
    cout << ret << endl;
    return 0;
}